import os

from PyQt5.QtCore import QUrl
from PyQt5.QtWebChannel import QWebChannel
from PyQt5.QtWebEngineWidgets import QWebEngineView



class ViewManager():
    def __init__(self):
        self.views = {
            'login':None,
            'main':None,
            'config':None
        }

        projectPath = os.getcwd().replace('views','')
        self.view_url = {
            'login':'file://'+ projectPath + '/ui/html/login.html',
            'main':'file://'+ projectPath + 'ui/html/main.html',
        }

    def createView(self,name,channel):
        self.views[name] = QWebEngineView()
        self.views[name].page().setWebChannel(channel)
        if name == 'login':
            self.views[name].setFixedWidth(300)
            self.views[name].setFixedHeight(400)


        if name == 'main':
            pass

        self.views[name].load(QUrl(self.view_url.get(name)))

    def showView(self,name):
        if name == 'login':
            self.views['login'].show()

if __name__ == '__main__':
    o_path = os.getcwd()
    print(o_path)